<!-- bottom -->
<template>
    <van-tabbar v-model="active" v-show="true"active-color="#ea5504">
      <van-tabbar-item :to="{name: 'Show'}">
        <span>发布会</span>
        <template #icon="props">
          <img :src="props.active ? icon3.active : icon3.inactive" />
        </template>
      </van-tabbar-item>
			<van-tabbar-item to="/">
				<span>签到</span>
				<template #icon="props">
					<img :src="props.active ? icon1.active : icon1.inactive" />
				</template>
			</van-tabbar-item>
			<van-tabbar-item :to="{name: 'Live'}">
				<span>直播</span>
				<template #icon="props">
					<img :src="props.active ? icon2.active : icon2.inactive" />
				</template>
			</van-tabbar-item>
		</van-tabbar>	
</template>

<script>
import { share } from '@/api/app.js'

export default {
  data() {
    return {
      active: 0,
      icon1: {
        inactive: require('../../assets/images/zhanhui/11.png'),
        active: require('../../assets/images/zhanhui/12.png'),
      },
      icon2: {
        inactive: require('../../assets/images/zhanhui/21.png'),
        active: require('../../assets/images/zhanhui/22.png'),
      },
      icon3: {
        inactive: require('../../assets/images/zhanhui/31.png'),
        active: require('../../assets/images/zhanhui/32.png'),
      },
      info: this.$store.state.active,
    }
  },
  created() {
    if(this.$route.name == 'Show') {
      this.active = 2
    }
    if(this.$route.name == 'Live') {
      this.active = 1
    }
    this.getShare()
  },
  methods: {
    getShare() {
      share({url: location.href.split('#')[0]}).then(res=> {
        var jweixin = require('jweixin-module')
        jweixin.config(JSON.parse(res))
        let _this = this
        jweixin.ready(function(){
          let title = _this.info.name
          let desc = _this.info.fname
          let img = _this.info.haibao
          let link = window.origin + process.env.VUE_APP_PATH
          console.log(_this.info)
          jweixin.updateAppMessageShareData({ 
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: img, // 分享图标
            success: function () {
              // 设置成功
            }
          })
          jweixin.updateTimelineShareData({ 
            title: title, // 分享标题
            link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: img, // 分享图标
            success: function () {
              // 设置成功
            }
          })
          
        })
      })
    }
  }

};
</script>

<style scoped>

</style>